﻿using Blog.Models.Entitys;
using Blog.Models.ReqModels;
using Blog.Service.Interface;
using Microsoft.AspNetCore.Mvc;

namespace Blog.WebApi.Controllers.System
{
    /// <summary>
    /// 用户管理
    /// </summary>
    [ApiController]
    [Route("api/sysuser")]
    public class SysUserController : BaseController
    {
        private readonly ILogger<SysUserController> _logger;
        private readonly ISysUserService _sysUserService;

        public SysUserController(ILogger<SysUserController> logger, ISysUserService sysUserService)
        {
            _logger = logger;
            _sysUserService = sysUserService;
        }

        [HttpPost("query")]
        public async Task<ActionResult> Query([FromBody] BaseQuery query)
        {
            return Success(await _sysUserService.QueryPage(query));
        }

        [HttpPost("save")]
        public async Task<ActionResult> Save([FromBody] IList<SysUser> users)
        {
            await _sysUserService.BatchInsert(users);
            return Success();
        }
    }
}
